package com.xuetang9.demo.ssm.common;

import java.util.ArrayList;
import java.util.List;

import org.springframework.ui.ModelMap;
import org.springframework.validation.BindingResult;
import org.springframework.validation.ObjectError;

import com.xuetang9.demo.ssm.domain.validation.Insert;
import com.xuetang9.demo.ssm.domain.validation.Update;

public final class ValidationUtis {

	private ValidationUtis() {
	}

	public static List<String> bindResultToList(BindingResult bindingResult) {
		List<String> errorMessages = new ArrayList<>();
		for (ObjectError error : bindingResult.getAllErrors()) {
			errorMessages.add(error.getDefaultMessage());
		}

		return errorMessages;
	}

}
